-
Notifications
You must be signed in to change notification settings - Fork 1.6k
RSACng.Encrypt used wrong "Pkcs1" link. #2849
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for noticing and fixing the exception issue @CXuesong. I left a suggestion for you to consider before we merge this.
|
||
-or- | ||
|
||
<paramref name="padding" /> is <see langword="null" />.</exception> | ||
<exception cref="T:System.Security.Cryptography.CryptographicException"> | ||
<paramref name="padding" /> does not equal <see cref="P:System.Security.Cryptography.RSASignaturePadding.Pkcs1" /> or <see cref="P:System.Security.Cryptography.RSASignaturePadding.Pss" />.</exception> | ||
<paramref name="padding" /> does not equal <see cref="P:System.Security.Cryptography.RSAEncryptionPadding.Pkcs1" />, or else the <see cref="P:System.Security.Cryptography.RSAEncryptionPadding.Mode" /> of <paramref name="padding" /> does not equal <see cref="F:System.Security.Cryptography.RSAEncryptionPaddingMode.Oaep" />.</exception> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<paramref name="padding" /> does not equal <see cref="P:System.Security.Cryptography.RSAEncryptionPadding.Pkcs1" />, or else the <see cref="P:System.Security.Cryptography.RSAEncryptionPadding.Mode" /> of <paramref name="padding" /> does not equal <see cref="F:System.Security.Cryptography.RSAEncryptionPaddingMode.Oaep" />.</exception> | |
<paramref name="padding" />.<see cref="P:System.Security.Cryptography.RSAEncryptionPadding.Mode" /> isn't equal to <see cref="P:System.Security.Cryptography.RSAEncryptionPadding.Pkcs1" /> or <see cref="F:System.Security.Cryptography.RSAEncryptionPaddingMode.Oaep" />.</exception> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that's the wrong "or", Maira. The exception is thrown if the padding mode isn't (pkcs1 or oaep), the only two supported modes. I read the "-or-" version as it throws always (throws if != pkcs1, and throws if != oaep... nothing is both, so throws always)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have copied this statement from the same documentation from the Decrypt
method, and I think that one should work.
dotnet-api-docs/xml/System.Security.Cryptography/RSACng.xml
Lines 220 to 230 in 056a526
<returns>The decrypted data.</returns> | |
<remarks>To be added.</remarks> | |
<exception cref="T:System.ArgumentNullException"> | |
<paramref name="data" /> is <see langword="null" />. | |
-or- | |
<paramref name="padding" /> is <see langword="null" />.</exception> | |
<exception cref="T:System.Security.Cryptography.CryptographicException"> | |
<paramref name="padding" /> does not equal <see cref="P:System.Security.Cryptography.RSAEncryptionPadding.Pkcs1" />, or else the <see cref="P:System.Security.Cryptography.RSAEncryptionPadding.Mode" /> of <paramref name="padding" /> does not equal <see cref="F:System.Security.Cryptography.RSAEncryptionPaddingMode.Oaep" />.</exception> | |
</Docs> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I'll reword my suggestion. If both conditions should be met, I think we should use and then. Perhaps we might also need to review the Decrypt exception condition @CXuesong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bartonjs can you review my suggestion?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<paramref name="padding" />.<see cref="P:System.Security.Cryptography.RSAEncryptionPadding.Mode" /> isn't equal to <see cref="P:System.Security.Cryptography.RSAEncryptionPadding.Pkcs1" /> or <see cref="F:System.Security.Cryptography.RSAEncryptionPaddingMode.Oaep" />.</exception>
looks reasonable to me.
Except that P:System.Security.Cryptography.RSAEncryptionPadding.Pkcs1 should probably be F:System.Security.Cryptography.RSAEncryptionPaddingMode.Pkcs1
Checking latest comments now... |
Done modification. In this case, may I also change the exception description in dotnet-api-docs/xml/System.Security.Cryptography/RSACng.xml Lines 228 to 230 in 056a526
|
Well, my update of RSA (including this file) is currently in PR, so rebasing should be put off a tiny bit (if I have to make another round of updates I can just take this into mine). And, yeah, making Decrypt match Encrypt seems good 😄 |
My updates to the RSA classes went in, so rebasing this and incorporating the change for Decrypt are now actionable. |
ping @carlossanlop @bartonjs Can one of you help me get the correct status of this one? What is the next action? |
Summary
padding
used inRSACng.Encrypt
accepts aRSAEncryptionPadding
instance, but exception description forCryptographicException
used link toRSASignaturePadding
. RSACng.Encrypt from RefSrc makes me thinking this exception description should be the same as the one fromRSACng.Decrypt
.